//ng创建and依赖
var app = angular.module('app',[
'ui.router'
]);
//初始化设置
app.run(
	['$rootScope', '$state',
		function($rootScope, $state) {
			//状态处理功能
			$rootScope.$state = $state;
			//登录状态
			$rootScope.isLogin = false;
			//认证状态
			$rootScope.isLogin = false;
			//路由变化事件处理
			//开始
			$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
				//alert(11);
			});
            //成功
			$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
				//alert(11);
			});
			//未找到
			$rootScope.$on('$stateNotFound', function(event, unfoundState, fromState, fromParams){
				
			});
			//失败
			$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error){
				
			});
		}
	]
);
//路由配置
app.config(['$logProvider', '$stateProvider','$urlRouterProvider', function($logProvider, $stateProvider,$urlRouterProvider){
	//错误路由跳转
	$urlRouterProvider
		.when('/c?id', '/contacts/:id')
		.otherwise('/');
	//路由配置			
	$stateProvider
		//首页
		.state('index',{
			url: '/',
			templateUrl: 'demo.html'
		})
		//
		.state('dd',{
			url: '/dd',
			template: 'demo.html'
		})
		//
		
	
}]);